<!DOCTYPE html>

<html lang="en" data-content_root="../../">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="viewport" content="width=device-width, initial-scale=1" />

    <title>Running many scripts at once &#8212; Pytch  documentation</title>
    <link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=03e43079" />
    <link rel="stylesheet" type="text/css" href="../../_static/classic.css?v=36340f97" />
    <link rel="stylesheet" type="text/css" href="../../_static/css/pytch-classic.css?v=0321735e" />
    
    <script src="../../_static/documentation_options.js?v=7f41d439"></script>
    <script src="../../_static/doctools.js?v=9bcbadda"></script>
    <script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
    
    <link rel="icon" href="../../_static/favicon.ico"/>
    <link rel="author" title="About these documents" href="../../about.html" />
    <link rel="index" title="Index" href="../../genindex.html" />
    <link rel="search" title="Search" href="../../search.html" />
    <link rel="next" title="About Pytch" href="../../about.html" />
    <link rel="prev" title="Defining sounds" href="sound-specs.html" /> 
  </head><body>
<div class="NavBar">
  <a href="../../../app/"><h1>Pytch</h1></a>
  <ul>
    <a href="https://pytch.scss.tcd.ie/"><li>About Pytch</li></a>
    <a href="../../index.html"><li>Help</li></a>
    <a href="../../../app/tutorials/"><li>Tutorials</li></a>
    <a href="../../../app/my-projects/"><li>My projects</li></a>
  </ul>
</div>
<div class="warning-work-in-progress">
  <p>These help pages are incomplete — we are working on it!</p>
</div>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="running-many-scripts-at-once">
<h1>Running many scripts at once<a class="headerlink" href="#running-many-scripts-at-once" title="Link to this heading">¶</a></h1>
<p>Scripts under hat blocks usually run to completion when that script is
triggered, before the screen is updated.  The exceptions are:</p>
<ul class="simple">
<li><p>when an ‘and wait’ call is made, e.g., <code class="docutils literal notranslate"><span class="pre">broadcast_and_wait()</span></code>;</p></li>
<li><p>during a <code class="docutils literal notranslate"><span class="pre">while</span></code> or <code class="docutils literal notranslate"><span class="pre">for</span></code> loop: one iteration of the loop runs
per display frame.</p></li>
</ul>
<p>TODO: Other syscalls also suspend for a frame; check and document
this.</p>
<p>One consequence of this is that if you have a very complex piece of
processing inside an event handler, your project might appear to have
crashed.  Try to keep things simple!</p>
<p>(The information above about <code class="docutils literal notranslate"><span class="pre">while</span></code> and <code class="docutils literal notranslate"><span class="pre">for</span></code> loops is slightly
simplified.  See the <a class="reference internal" href="../developer/threading-model.html#threading-model"><span class="std std-ref">Threading Model</span></a> help if you would like to
know the full details, although most Pytch programs will not have to
worry about this.)</p>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="Main">
        <div class="sphinxsidebarwrapper"><ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../../webapp/user/index.html">Using the Pytch web app</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Writing Pytch programs</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="sprite.html">Sprites</a></li>
<li class="toctree-l2"><a class="reference internal" href="stage.html">The stage</a></li>
<li class="toctree-l2"><a class="reference internal" href="non-hat-blocks.html">Scratch blocks → Pytch functions and methods</a></li>
<li class="toctree-l2"><a class="reference internal" href="pytch-module-functions.html">Functions in the pytch module</a></li>
<li class="toctree-l2"><a class="reference internal" href="hat-blocks.html">Scratch hat blocks → Pytch decorators</a></li>
<li class="toctree-l2"><a class="reference internal" href="costume-specs.html">Defining costumes</a></li>
<li class="toctree-l2"><a class="reference internal" href="backdrop-specs.html">Defining backdrops</a></li>
<li class="toctree-l2"><a class="reference internal" href="sound-specs.html">Defining sounds</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Running many scripts at once</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../about.html">About Pytch</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../contact.html">Contact</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../developer.html">Developer documentation</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../legal/index.html">Legal information</a></li>
</ul>
<div class="docs-home-link"><hr>
  <ul>
    <li>
      <a href="../../index.html">Pytch help home</a>
    <li>
  </ul>
</div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
  </body>
</html>